<template>
  <div class="detailPageCss">
    <div class="titleCss">查看现状评价或定期检测报告</div>
    <div class="bodyCss">
      <div class="tableCss">
        <el-table max-height="650" :data="tableData" border style="width: 100%">
          <el-table-column
            prop="enterpriseName"
            label="用工单位名称"
            min-width="300"
             align="center"
          >
          </el-table-column>
          <el-table-column prop="importType"  align="center" label="报告类型" min-width="100">
            <template #default="scope">
              {{ data2Map[scope.row.importType] }}
            </template>
          </el-table-column>
          <el-table-column prop="importTime"  align="center" label="日期" min-width="100">
          </el-table-column>
          <el-table-column prop="importUrl"  align="center" label="报告文件" min-width="200">
            <template #default="scope">
              <el-button @click="donwloadFile(scope.row.importUrl)" type="text">
                <img src="../../../../../assets/images/file_icon.png" alt="">
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="pageNum"
        :limit.sync="pageSize"
        @pagination="getList"
      />
    </div>
    <div class="bottomBtnCss">
      <el-button @click="goBackBtn">返回</el-button>
    </div>
  </div>
</template>

<script>
import { getCurrentDay } from "@/utils/business.js";
import { enterpriseimport } from "@/api/zhangping/zpEnterpriseInfo";
export default {
  props: {
    pageType: {
      type: Number,
      default: () => 0,
    },
  },
  data() {
    return {
      tableData: [],
      data2Map: {
        0: "现状评价",
        1: "定期检测",
      },
      pageNum: 1,
      pageSize: 10,
      total:0
    };
  },
  created() {
    this.getList();
  },
  methods: {
    async getList() {

      let res = await enterpriseimport({
        creditCode: this.$route.query.id,
        pageNum: this.pageNum,
        pageSize: this.pageSize,
      });
      if (res.code == 200) {
        this.tableData = res.rows;
        this.total = res.total
      }
    },
    goBackBtn() {
      this.$router.back();
    },
    donwloadFile(url){
     location.href = 'http://36.137.225.215:7799/prod-api' + url
    }
  },
};
</script>

<style lang="scss" scoped>
.detailPageCss {
  overflow: hidden;
  position: relative;
  background-color: #fff;
  padding: 20px;
  border-radius: 10px;
  height: calc(100vh - 66px - 40px);
  display: flex;
  flex-direction: column;
  .titleCss {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
  }
  .bodyCss {
    margin-top: 40px;
    width: calc(100% - 40px);
    margin-left: 10px;
    height: calc(100% - 120px);
    overflow-y: auto;
    padding-bottom: 10px;
    .tableCss {
      margin-top: 10px;
      position: relative;
    }
  }
  .bottomBtnCss {
    margin-top: auto;
    text-align: right;
  }
}
</style>
